import moment from 'moment'
function generateRandomString(length) {
  const characters =
    'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
  let result = ''
  for (let i = 0; i < length; i++) {
    result += characters.charAt(Math.floor(Math.random() * characters.length))
  }
  return result
}

function generateRandomNumber(min, max) {
  return Math.floor(Math.random() * (max - min + 1)) + min
}

function generateRandomArray(length, min, max) {
  const result = []
  for (let i = 0; i < length; i++) {
    result.push(generateRandomNumber(min, max))
  }
  return result
}

export function generateRandomData(dataType, options) {
  if (dataType == null) {
    return null
  }
  if (dataType === 0) {
    return generateRandomString(10)
  } else if (dataType === 1 || dataType === 5) {
    return generateRandomNumber(0, 100)
  } else if (dataType === 2) {
    return moment().format('HH:mm')
  } else if (dataType === 3) {
    return generateRandomArray(2, 0, 100)
  } else if (dataType === 4) {
    return true
  } else if (dataType === 6 || dataType === 7) {
    return moment()
  }
  throw new Error('Invalid data type')
}
